#!/bin/bash
golo_cid=$( cat /opt/openresty/nginx/scripts/golo.conf |grep cid |tr -d "cid=")
. $nginxurl/scripts/golo.conf
source $ROS_GOLO_WS_PATH
roscd websocket-client
WEBSOCK_DIR=$(pwd)
cd /home/nuc/
if [ -d ".golo_ws" ]
    then
    source $ROS_GOLO_WS_PATH 
    else
    source $ROS_GOLO_WS_PATH
    fi
cd $WEBSOCK_DIR/scripts
if [ -f "config_cid.py" ]
    then
    websocket_cid=$( cat config_cid.py |grep cid |tr -d "cid=" |awk '{print $1}')
    else
    websocket_cid=$( cat config.py |grep cid |tr -d "cid=" |awk '{print $1}')
    fi
sudo sed -i "s/$golo_cid/$websocket_cid/g" /opt/openresty/nginx/scripts/golo.conf
if [ -f "config_cid.py" ]
    then
        cd ../.. && rm -rf websocket-client &&  git clone http://git.51golo.com:10080/lujinji/websocket-client.git 
    else
        cd ../.. && rm -rf websocket-client &&  git clone -b more_path http://git.51golo.com:10080/lujinji/websocket-client.git 
    fi
sleep 20
. /opt/openresty/nginx/scripts/golo.conf
cd $GOLO_WS_PATH/golo
sudo sed -i "s/1000000/$golo_cid/g" $GOLO_WS_PATH/golo/websocket-client/scripts/config_cid.py
chmod 777 websocket-client/ -R
